import React, { useState } from 'react'
import {getlist} from '../../../api/index'
import {
    Form,
    Input,
    Button,
    Dialog,
    DatePicker,
} from 'antd-mobile'
import dayjs from 'dayjs'
import '../../../App.scss'
function My() {
   
    const onFinish = (values: any) => {
        Dialog.alert({
            content: JSON.stringify(values),
        })
        getlist(values).then(resp=>{
            return console.log(values)
        })
        
    }
    const hand=()=>{
        // console.log(e)
        // onFinish(values)
    }
    const [pickerVisible, setPickerVisible] = useState(false)
    return (
        <div>
            <div className="head">
                <p>&lt;</p>
                <p>健康档案</p>
                <p onClick={()=>hand()}>保存</p>
            </div>
            <Form
                onFinish={onFinish}
                footer={
                    <Button block type='submit' color='primary' >
                        保存
                    </Button>
                }
            >
                <Form.Item
                    style={{display:'flex'}}
                    name='name'
                    label='身份证号'
                    rules={[{ required: true, message: '身份证号不能为空' }]}
                >
                    <Input placeholder='请输入身份证号' />
                </Form.Item>
                <Form.Item name='shen' label='身高'>
                    <Input placeholder='请输入身高' />
                </Form.Item>

                <Form.Item name='ti' label='体重'>
                    <Input placeholder='请输入体重' />
                </Form.Item>

                <Form.Item name='bm' label='BMI'>
                    <Input placeholder='请输入BMI' />
                </Form.Item>
                <Form.Item name='yao' label='腰围'>
                    <Input placeholder='请输入腰围' />
                </Form.Item>
                <Form.Item name='xi' label='吸烟史'>
                    <Input placeholder='请输入吸烟史' />
                </Form.Item>
                <Form.Item
                    name='birthday'
                    label='饮酒史'
                    trigger='onConfirm'
                    onClick={() => {
                        setPickerVisible(true)
                    }}
                >
                    <DatePicker
                        visible={pickerVisible}
                        onClose={() => {
                            setPickerVisible(false)
                        }}
                    >
                        {value =>
                            value ? dayjs(value).format('YYYY-MM-DD') : '请选择'
                        }
                    </DatePicker>
                </Form.Item>




            </Form>
        </div>
    )
}

export default My
